﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;

namespace AiQiuQuan.Sport.Core
{
    /// <summary>
    /// cap 扩展
    /// </summary>
    public static class CapExtensions
    {
        /// <summary>
        /// cap redis sqlserver服务
        /// </summary>
        public static IServiceCollection AddRedisSqlserverCap<TDbContext>(this IServiceCollection services, IConfiguration configuration) where TDbContext : DbContext
        {
            services.AddCap(capOption =>
            {
                capOption.UseEntityFramework<TDbContext>();
                capOption.UseRedis(configuration["CapRedisConnStr"]);
                capOption.UseDashboard();
                capOption.UseDispatchingPerGroup = true;
                capOption.TopicNamePrefix = "cap.aiqiuquan.";
                capOption.FailedRetryCount = 10;
            });
            return services;
        }
    }
}
